Skip to content
Scott edited this page Jun 4, 2025 · 2 revisions

Welcome to the Roslyn-CSharp-2.0-Samples wiki!

Check out the following code samples to get started, or if you are upgrading from v1.x, you may wish to check out the upgrade guide to see what has changed between versions.

00 - Load assembly

Shows how to load an existing assembly into a Roslyn C# script domain.

01 - Compile

The following examples show how to compile various forms of input source code but not execute. This works on all platforms including IL2CPP if you just need to produce assemblies or verify that C# code is valid.

02 - Compile And Load

_The following examples show how to compile and load various forms on input source code for execution. This is limited to Mono platforms buy default, but can be supported on any platform if using dotnow. See the dedicated dotnow integration guide for more info.

03 - Compile And Load Main

The following examples show how to compile, load and return the main type defined in compiled code. This is useful if you are just compiling single source inputs that will only have 1 class for example, but is also useful in other cases since by default it will select MonoBehaviour types to be the main type.

04 - Referencing

The following examples cover assembly referencing which allows compiled code to reference any assembly that is part of the game, external and also other compiled assemblies.

More samples to come soon...

Clone this wiki locally